package com.zhaoyu.user.controller;

import com.zhaoyu.apis.user.ApUserRealNameControllerApis;
import com.zhaoyu.common.constants.UserConstants;
import com.zhaoyu.model.common.dtos.ResponseResult;
import com.zhaoyu.model.user.dtos.AuthDto;
import com.zhaoyu.user.service.ApUserRealNameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/auth")
public class ApUserRealNameController implements ApUserRealNameControllerApis {

    @Autowired
    private ApUserRealNameService apUserRealNameService;

    @Override
    @PostMapping("/list") // json格式的数据
    public ResponseResult findByStatusAndPageApUserRealname(@RequestBody AuthDto authDto) {
        return apUserRealNameService.findByStatusAndPage(authDto);
    }

    /**
     * 测试(postman)：
     *      "id": 8
     *      "status": 9
     */
    @Override
    @PostMapping("/authPass") // json格式的数据
    public ResponseResult authPassApUserRealname(@RequestBody AuthDto authDto) {
        /**
         * 状态
         0 创建中
         1 待审核
         2 审核不通过
         9 审核通过
         */
        return apUserRealNameService.updateStatusById(authDto, UserConstants.PASS_AUTH); // 审核通过
    }

    @Override
    @PostMapping("/authFail") // json格式的数据
    public ResponseResult authFailApUserRealname(@RequestBody AuthDto authDto) {
        return apUserRealNameService.updateStatusById(authDto, UserConstants.FAIL_AUTH); // 审核不通过
    }

}